package com.demo.web.Config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;


import javax.servlet.MultipartConfigElement;

@Configuration
public class fileUploadSettings {

    //单个文件上传大小
    private String maxFileSize="100MB";
    //总文件上传大小
    private String maxRequestSize="1000MB";

    @Bean
    public MultipartConfigElement multipartConfigElement(){
        //创建配置对象
       MultipartConfigFactory factory=new MultipartConfigFactory();
       //设置单个数据大小
        factory.setMaxFileSize(DataSize.parse(maxFileSize));
        //设置总文件上传大小
        factory.setMaxRequestSize(DataSize.parse(maxRequestSize));

        return factory.createMultipartConfig();

    }

}
